<?php
include './const.php';

//二、判断数据库重复值
if (isset($_POST['username'])) { //判断前端是否传递锅来了数据
    $username = $_POST['username']; //获取数据储存
    // echo $username;
    $chongfuName = $const->query("SELECT * FROM registry_login WHERE username='$username' ");

    //重复name
    if ($chongfuName->fetch_assoc()) {
        echo 'errName';
    } else {
        echo 'yesName';
    }
}
//panduanshouji
if (isset($_POST['tel'])) { //判断前端是否传递锅来了数据
    $tel = $_POST['tel']; //获取数据储存
    // echo $username;
    $tel = $const->query("SELECT * FROM registry_login WHERE tel='$tel' ");

    //重复name
    if ($tel->fetch_assoc()) {
        echo 'errName';
    } else {
        echo 'yesName';
    }
}

//丽娜姐数据库
if (isset($_POST['btn'])) {

    if (isset($_POST['username'])) { //判断前端是否传递锅来了数据
        $username = $_POST['username']; //获取数据储存
        // echo $username;
        $chongfuName = $const->query("SELECT * FROM registry_login WHERE username='$username' ");

        //重复name
        if ($chongfuName->fetch_assoc()) {
            header("location:http://127.0.0.1/SAMSUNGproject/frontend/registry.html");
        } else {
            $username = $_POST['username'];
            $tel = $_POST['tel'];
            $password = sha1($_POST['password']);
            $yespass = sha1($_POST['yespass']);

            //插入数据
            $const->query("INSERT registry_login VALUES(null,'$username','$tel','$password','$yespass')");

            //数据插入跳转登录页面
            header("location:http://127.0.0.1/SAMSUNGproject/frontend/login_login.html");
        }
    }
};
